package com.blog.response;

import com.blog.constant.Constant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Description 这是结果集的封装
 * @Author XiaoLin
 * @Date 2021/2/19 20:07
 */
@Data
@AllArgsConstructor
public class ResponseResult {
  private boolean success;
  private Integer code;
  private String message;
  private Object date;

  public ResponseResult(boolean success, Integer code) {
    this.success = success;
    this.code = code;
  }

  public ResponseResult(boolean success, Integer code, String message) {
    this.success = success;
    this.code = code;
    this.message = message;
  }

  public ResponseResult(boolean success) {
    this.success = success;
  }


  public static ResponseResult SUCCESS() {
    return new ResponseResult(true,Constant.SUCCESS);
  }

  public static ResponseResult SUCCESS(String message) {
    return new ResponseResult(true,Constant.SUCCESS,message);
  }

  public static ResponseResult SUCCESS(String message,Object date) {
    return new ResponseResult(true,Constant.SUCCESS,message,date);
  }

  public static ResponseResult FAILED(String message) {
    return new ResponseResult(false,Constant.FAILED,message);
  }


  public static ResponseResult FAILED() {
    return new ResponseResult(false,Constant.FAILED);
  }
}
